﻿@model ShareIt_MVC3.Models.MyShareItViewModel

@{
    ViewBag.Title = "MeinShareIt";
    var colorCheck = true;
    var colorCheck2 = true;
    var colorCheck3 = true;
    var colorCheck4 = true;
    var colorCheck5 = true;
}
<div class="post">
<h1>Mein ShareIt</h1>
<br>
<br />
<table>
<tr>
<th style="color:#000; background:#CCFFFF; font-size:larger"> Meine Credits: @Model.MyUser.Credits</th>
</tr>
</table>
<div >
<br />
<br />
</div>
<h2>Meine Bücher</h2>

@if (Model.MyResources.Count == 0)
{
    <p>Sie haben noch kein Buch eingestellt. @Html.ActionLink("Buch einstellen", "Create", "Resources")</p>
}
else
{
<table>
    <tr>
        <th>Titel</th>
        <th>Autor</th>
        <th>Verleihbar?</th>
        <th>Aktion</th>
    </tr>
    @foreach (var resource in Model.MyResources)
    {
        <tr @((colorCheck == true) ? "class=colored-row" : "")>
            <td>@resource.Title</td>
            <td>@resource.Author</td>
            <td>@((resource.Active == true) ? "Ja" : "Nein")</td>
            <td>@Html.ActionLink("Editieren", "Edit", new { controller = "Resources", id = resource.ID })</td>
        </tr>
        
           if (colorCheck == false)
           {
               colorCheck = true;
           }
           else
           {
               colorCheck = false;
           }
    }

</table>
}
<br />
<br />

<h2>Aktuell ausgeliehene Bücher</h2>
@if (Model.BorrowedResources.Count == 0)
{
    <p>Sie haben zur Zeit kein Buch ausgeliehen. @Html.ActionLink("Buch ausleihen", "Borrowable")</p>
}
else
{
<table>
    <tr>
        <th>Titel</th>
        <th>Autor</th>
        <th>Ausleihdatum</th>
        
        <th>Verleiher</th>
    </tr>

    @foreach (var lending in Model.BorrowedResources)
    {
        
        <tr @((colorCheck2 == true) ? "class=colored-row" : "")>
            <td>@lending.Resource.Title</td>
            <td>@lending.Resource.Author</td>
            <td>@lending.DateOfLending</td>
            
            <td><a href="mailto:@lending.Resource.Owner.EMail">@lending.Resource.Owner.Username</a></td>
        </tr>
        if (colorCheck2 == false)
        {
            colorCheck2 = true;
        }
        else
        {
            colorCheck2 = false;
        }
    }

</table>
}

<br />
<br />

<h2>Aktuell verliehene Bücher</h2>
@if (Model.LentResources.Count == 0)
{
    <p>Im Moment ist keines Ihrer Bücher verliehen.</p>
}
else
{
<table>
    <tr>
        <th>Titel</th>
        <th>Autor</th>
        <th>Verleihdatum</th>
        
        <th>Entleiher</th>
        <th>Aktion</th>
     
    </tr>
    @foreach (var lending in Model.LentResources)
    {

        <tr @((colorCheck3 == true) ? "class=colored-row" : "")>
            <td>@lending.Resource.Title</td>
            <td>@lending.Resource.Author</td>
            <td>@lending.DateOfLending</td>
            
            <td><a href="mailto:@lending.Lender.EMail">@lending.Lender.Username</a></td>
            <td>@if (lending.DateOfReturning == "")
                { @Html.ActionLink("Buch wieder erhalten", "Reacquire", new { id = lending.ID }) }</td>
        </tr>
        
        if (colorCheck3 == false)
        {
            colorCheck3 = true;
        }
        else
        {
            colorCheck3 = false;
        }
    }

</table>
}
<br /><br />
<h1>Historie</h1>

<h2>Verliehene Bücher</h2>
@if (Model.LentResourcesHistory.Count == 0)
{
    <p>Sie haben bisher noch keine Bücher verliehen.</p>
}
else
{
<table>
    <tr>
        <th>Titel</th>
        <th>Autor</th>
        <th>Verleihdatum</th>
        <th>Rückgabedatum</th>
        <th>Entleiher</th>
        <th>Aktion</th>
     
    </tr>
    @foreach (var lending in Model.LentResourcesHistory)
    {

        <tr @((colorCheck4 == true) ? "class=colored-row" : "")>
            <td>@lending.Resource.Title</td>
            <td>@lending.Resource.Author</td>
            <td>@lending.DateOfLending</td>
            <td>@lending.DateOfReturning</td>
            <td><a href="mailto:@lending.Lender.EMail">@lending.Lender.Username</a></td>
            <td>@if (lending.DateOfReturning == "")
                { @Html.ActionLink("Buch wieder erhalten", "Reacquire", new { id = lending.ID }) }</td>
        </tr>
        
                if (colorCheck4 == false)
                {
                    colorCheck4 = true;
                }
                else
                {
                    colorCheck4 = false;
                }
    }
</table>
}

<h2>Entliehene Bücher</h2>
@if (Model.BorrowedResourcesHistory.Count == 0)
{
    <p>Sie haben bisher noch keine Bücher ausgeliehen.</p>
}
else
{
<table>
    <tr>
        <th>Titel</th>
        <th>Autor</th>
        <th>Verleihdatum</th>
        <th>Rückgabedatum</th>
        <th>Entleiher</th>
        <th>Aktion</th>
     
    </tr>
    @foreach (var lending in Model.BorrowedResourcesHistory)
    {

        <tr @((colorCheck5 == true) ? "class=colored-row" : "")>
            <td>@lending.Resource.Title</td>
            <td>@lending.Resource.Author</td>
            <td>@lending.DateOfLending</td>
            <td>@lending.DateOfReturning</td>
            <td><a href="mailto:@lending.Lender.EMail">@lending.Lender.Username</a></td>
            <td>@if (lending.DateOfReturning == "")
                { @Html.ActionLink("Buch wieder erhalten", "Reacquire", new { id = lending.ID }) }</td>
        </tr>
        
                if (colorCheck5 == false)
                {
                    colorCheck5 = true;
                }
                else
                {
                    colorCheck5 = false;
                }
    }
</table>
}

</div>